<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.28</title>
</head>

<body>
<?php
	if(isset($_POST['hoten']))
	{
		$hoten=$_POST['hoten'];
		$arr = explode(' ',trim($hoten));
		$arrlen=count($arr);
		$ho=$arr[0];
		$ten=$arr[$arrlen-1];
		$dem="";
		for($i=1;$i<$arrlen-1;$i++)
			$dem.=$arr[$i].' ';
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_28.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#000066" style="text-align: center; font-size: 24px; color: #FFF; font-weight: bold; font-style: italic;">
      <td colspan="2">TÁCH HỌ VÀ TÊN</td>
    </tr>
    <tr>
      <td bgcolor="#66CCCC">Họ và tên:</td>
      <td bgcolor="#66CCCC"><input name="hoten" type="text" id="hoten" value="<?php echo $_POST['hoten'];?>" size="50" /></td>
    </tr>
    <tr>
      <td bgcolor="#66CCCC">Họ:</td>
      <td bgcolor="#66CCCC"><input name="ho" type="text" disabled="disabled" id="ho" value="<?php echo $ho;?>" /></td>
    </tr>
    <tr>
      <td bgcolor="#66CCCC">Tên đệm:</td>
      <td bgcolor="#66CCCC"><input name="dem" type="text" disabled="disabled" id="dem" value="<?php echo $dem;?>" /></td>
    </tr>
    <tr>
      <td bgcolor="#66CCCC">Tên:</td>
      <td bgcolor="#66CCCC"><input name="ten" type="text" disabled="disabled" id="ten" value="<?php echo $ten;?>" /></td>
    </tr>
    <tr style="text-align: center">
      <td colspan="2" bgcolor="#66CCCC"><input style="background-color:#0F9" type="submit" name="submit" id="submit" value="Tách Họ Tên" /></td>
    </tr>
  </table>
</form>
</body>
</html>